clear
rng default
load IdSetM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% Projections in one dimension %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ntypes_m=3;
U_1=cell(ntypes_m,1);
U_2=cell(ntypes_m,1);
U_3=cell(ntypes_m,1);
for x=1:ntypes_m
    U_1{x}=[min(IdSetM{x}(:,2)); max(IdSetM{x}(:,2))];
    U_2{x}=[min(IdSetM{x}(:,3)); max(IdSetM{x}(:,3))];
    U_3{x}=[min(IdSetM{x}(:,4)); max(IdSetM{x}(:,4))];
end

save('U_intervals.mat', 'U_1', 'U_2', 'U_3')


clearvars -except IdSetM ntypes_m


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% Projections in two dimensions %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load U_CS

for x=1:ntypes_m
    %u2x u3x
    M=unique([IdSetM{x}(:,3) IdSetM{x}(:,4)], 'rows', 'stable'); 
    figure
    scatter(M(:,1), M(:,2), 60,'k', 'filled')
    hold on
    scatter(U_CS(x,2), U_CS(x,3), 60,'r', 'filled')
    xlabel(sprintf('U_{%d2}',x),'FontSize', 25) 
    ylabel(sprintf('U_{%d3}',x),'FontSize', 25)
    xlim([-20 20])
    ylim([-20 20])
    box on
    set(gca, 'ytick',-20:10:20,'xtick',-20:10:20,'FontSize',20)
    saveas(gcf,sprintf('U_%d2_%d3.jpg',x,x))
     
end


%close all





